import uSwipeActionItem from "@/components/uni-swipe-action-item/uni-swipe-action-item.vue";
import uniSwipeAction from "@/components/uni-swipe-action/uni-swipe-action.vue"
export default {
		data() {
			return {
				editId: '',
				editContent:'',
				list: [],
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#EE2437' // 删除按钮背景  红的
					}
				}],
				isNullData: false,
				pageNum: 1,
				tipsTitle: '',
				scrollTop:0,
				showModal:false,
				showContent:'',
				showModal1:false,
				showContent1:''
			}
		},
		components: {
			uniSwipeAction,
			uSwipeActionItem
		},
		onLoad() {
			this.list = []
			this.pageNum = 1;
			this.tipsTitle = ''
			this.planList();
		},
		onShow(){
			// this.list = this.list && this.list.map((res)=>{
			// 	if(res.id == this.editId){
			// 		res = this.editContent;
			// 		res.createdDate = filterData2(new Date(this.editContent.createdDate).getTime())
			// 	}
			// 	return res;
			// }) || []
		},
		onReachBottom(e) {
			if (this.isNullData) {
				setTimeout(() => {
					this.tipsTitle = '我也是有底线的~'
				},1000)
				return;
			}
			this.tipsTitle = '加载中~'
			setTimeout(() => {
				this.pageNum++
				this.planList();
			}, 1000);

		},
		onPageScroll(e){
			this.scrollTop = e.scrollTop
		},
		onPullDownRefresh() {
			this.list = []
			this.isNullData = false
			this.pageNum = 1;
			this.tipsTitle = ''
			this.planList();
		},
		methods: {
			toAdd() {
				uni.navigateTo({
					url: '/pages/quickly/intervenscheme/creat'
				})
			},
			planList() {
				if(this.isNullData){
					return;
				}
				this.$api.InterventionPlanList({
					pageNum: this.pageNum,
					pageSize: 20,
					planType: 'isToday',
					// healthId: ''
				}).then((res) => {
					if (res.data.returnCode == 200) {
						uni.stopPullDownRefresh();
						this.list = this.list.concat(res.data.result.elements || []);
						if (this.list.length >= res.data.result.count) {
							this.isNullData = true
						}
						
					}
				})
			},
			carryOut(id) {
				this.showModal1 = true
				this.showContent1 = '是否执行此计划。'
				this.carryId = id;
			},
			Modalconfirm1(){
				const _this = this;
				_this.$api.InterventionrunPlan(this.carryId).then((res)=>{
					if (res.data.returnCode == 200) {
						_this.$api.InterventionPlanList({pageNum: 1,pageSize: 20,planType: 'isToday',}).then((res) => {
							if (res.data.returnCode == 200) {
								_this.list = res.data.result.elements || []
							}
						})
					}
				})
			},

			bindClick(e) {
				this.showModal = true
				this.showContent = '是否删除此干预计划'
				this.delItem = e
			},
			Modalconfirm(){
				const _this = this;
				_this.$api.Interventiondelete(_this.delItem.id).then((res)=>{
					if(res.data.returnCode == 200){
						_this.$api.InterventionPlanList({pageNum: 1,pageSize: 20,planType: 'isToday',}).then((res) => {
							if (res.data.returnCode == 200) {
								_this.list = res.data.result.elements
							}
						})
					}
				})
			},
		}
	}